<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <style>
        div{
            height:100px;
            width:100px;
            background: red;
        }
    </style>
</head>
<body>
    <!--is("visible")判断一个元素是否可见
         fadeIn
         fadeOut
         fadeToggle()
         fadeTo(speed,opacity,callback)  //渐隐到一种透明度-->
    <div>

    </div>
    <button>btn</button>
    <script>
        $("button").click(function(){
/*             if($("div").is(":visible")){
                $("div").fadeOut(1000)
            }else{
                $("div").fadeIn(1000)
            } */
            $("div").fadeTo(1000,.2)
        })
        $("div").mouseover(function(){
            $(this).fadeTo(1000,.2)
        }).mouseout(function(){
            $(this).fadeTo(1000,.8)
        })
    </script>
</body>
</html>